package com.xy.lang.enums;

import com.xy.lang.domain.KeyValue;

import java.util.ArrayList;
import java.util.List;

/**
 * 温度枚举，一般用于货物的存储或运输的方式上的分类
 */
public enum TemperatureEnum implements CodeEnum {

    ORDINARY(1, "常温"),
    COLD(2, "冷藏"),
    FREEZE(3, "冷冻");

    private int code;
    private String name;

    TemperatureEnum(int code, String name) {
        this.code = code;
        this.name = name;
    }

    @Override
    public int getCode() {
        return code;
    }

    public String getName() {
        return name;
    }

    public KeyValue<Integer, String> toKeyValue() {
        return new KeyValue<>(this.code, this.name);
    }

    public static List<KeyValue<Integer, String>> list() {
        TemperatureEnum[] enums = TemperatureEnum.values();
        List<KeyValue<Integer, String>> list = new ArrayList<>();
        for (TemperatureEnum e : enums) {
            list.add(e.toKeyValue());
        }
        return list;
    }

}
